package com.wei.violet.utils

import org.apache.log4j.{Level, Logger}
import org.apache.spark.{SparkConf, SparkContext}

object appdict2Redis {

  Logger.getLogger("org").setLevel(Level.WARN)
  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf()
      .setAppName("将终端设备统计结果添加到mysql数据库中")
      .setMaster("local[*]")
      .set("spark.serizlizer", "org.apache.spark.serializer.KryoSerializer")

    val sc = new SparkContext(conf)

    val appdict=sc.textFile("F:\\bigdataFile\\data\\app_dict.txt")

    val appmapped = appdict.map(_.split("\\t",-1)).filter(_.length>=5).map(str => {
      (str(4),str(1))
    })



    appmapped.foreachPartition(a=>{
      val  jedis=Jpools.getJedis
      a.foreach(a=>{
        jedis.hset("appdict",a._1,a._2)
      })
      jedis.close()


    })

  }

}
